-
Notifications
You must be signed in to change notification settings - Fork 101
Separate type-checking from ParsingModule to new TypeCheckModule trait #770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate type-checking from ParsingModule to new TypeCheckModule trait #770
Conversation
…entations Co-authored-by: Ph0enixKM <[email protected]>
Co-authored-by: Ph0enixKM <[email protected]>
|
@copilot In the |
This comment was marked as resolved.
This comment was marked as resolved.
… core syntax modules Co-authored-by: Ph0enixKM <[email protected]>
|
@copilot Resolve clippy errors |
Co-authored-by: Ph0enixKM <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
|
@copilot this PR is almost ready. The problem now why the tests are failing is because it doesn't recursively type-checks nested syntax modules. For instance: In this example |
Co-authored-by: Ph0enixKM <[email protected]>
... Fixed the recursive type checking issue in commit ad6e9ac. Problem: Modules with Solution: Replaced no-op implementations with proper recursive type checking for 15+ modules including:
Verification:
|
Ph0enixKM
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot some minor issues
… add test Co-authored-by: Ph0enixKM <[email protected]>
|
I'll probably get back to it this sunday. I have too much going on right now |
|
@copilot rewrite this PR's description from scratch. |
|
@copilot rewrite the PR description from scratch and make it concise |
This comment was marked as resolved.
This comment was marked as resolved.
* [docs] Use version instead of master when linking (#649) * Write docs to standard output (#655) * Write docs to stdout with target "-". * Minor refactoring. * Make Clippy happy. * Unindent main block (#654) * Unindent code in main block. * Cap indentation level at zero. * Add TODO comment as requested. * Improve docs usage links (#653) * Implement failability as function property instead of type (#642) Removes the Failable type. Implements failability as a property of a function, instead. --------- Co-authored-by: hdwalters <[email protected]> Co-authored-by: Phoenix Himself <[email protected]> * fix: validate function argument names for duplicates (#680) * feat(install): removed from repo (#644) * replace_regex: remove bash word boundary when detecting gnused (#686) * New translation modules architecture (#678) * feat: initial commit * fix: validity tests * fix: some of the stdlib errors * fix: some tests * fix: stdlib tests * fix: additional error * fix: cargo clippy * fix: wrong quoting * fix: wrong init value * fix: block rendering * feat: improve block formatting * fix: shellcheck issues * feat: add more tests * fix: shellcheck issues * fix: clippy error * feat: add ternary tests * fix: escaping of slices * impl From<String> for CommentFragment * simplify path for use * refactor match for readability Co-authored-by: Huw Walters <[email protected]> * refactor &*self.index -> self.index.as_ref() * add trailing comma to match block * rigidly match all requirements to be 1 1 0 * remove a redundant blank line * simplify echoing the array * reword unreachable code * refactor constructor to give every function its own line * refactor: render -> to_string * fix: trailing commas * refactor: rename fragment structures * refactor: symbols and block fn name * refactor: add context to text escaped regular character test * refactor: remove padding in doc comments * fix: comment and compound * refactor: remove unnecessary files * refactor: compount -> list * refactor: set_quoted -> with_quotes * refactor: iter loop * refactor: fragments(raw:) -> raw_fragment() * refactor: formatting * refactor: improve readability * refactor: variable * refactor: finalize addressing concerns * fix: clippy errors --------- Co-authored-by: b1ek <[email protected]> Co-authored-by: Huw Walters <[email protected]> * Added Git version at build-time (#685) * test: Use the bash container and a matrix strategy for bash versions (#616) Co-authored-by: Phoenix Himself <[email protected]> Co-authored-by: Daniele Scasciafratte <[email protected]> Co-authored-by: b1ek <[email protected]> * Replace Amber text interpolation with Bash parameter expansion (#592) Co-authored-by: Huw Walters <[email protected]> Co-authored-by: Daniele Scasciafratte <[email protected]> * fix: base_base_image -> base_bash_image (#704) Co-authored-by: Phoenix Himself <[email protected]> * Add Variable Statement Translation Fragment (#698) * run workflows on main and staging (#705) * vscode debug profile (#692) * Add function that returns installed bash version (#703) * Fix CI/CD regarding bash_version PR (#708) * feat: add bash version comparison function * feat: add star expansion to var expr * feat: add lexical comparison * feat: add array comparison operator for numerical comparisons * feat: add lexical comparison operators * feat: add function that returns current bash version * fix: clippy * refactor: remove leftover note * refactor: improve readability of version comparison * feat: update error messages * refactor: componentize parts of lexical ordering function * feat: add underscord before 'i' variable * feat: rename 'star expansion' to 'array to string' * refactor: rename variable * fix: improve logic of array comparison * feat: add tests for different sizes * feat: add tests for different sizes - text * fix: operators * fix: bad tests * fix: eq fragment unused * feat: pluralize * fix: CI/CD * Fix CI pipeline for old Bash versions and add macOS support. (#701) * feat: add macOS CI testing workflow * fix: std text replace not failing * fix: make replace compatible with bash 4.2 * fix: base_base_image -> base_bash_image * doc: minor styling * fix: replace function * fix: regex basic test * fix: array_extract_at test * fix: date posix test * fix: Update condition to filter Bash 4.4 or later (#709) * fix: Use the approch for Bash 4.3 or newer * Update src/std/text.ab Co-authored-by: Phoenix Himself <[email protected]> * Update text.ab --------- Co-authored-by: Phoenix Himself <[email protected]> * Feat: Improve date library (#712) * fix: date library * Update src/std/date.ab Co-authored-by: Hubert Jabłoński <[email protected]> * Update src/std/date.ab Co-authored-by: Hubert Jabłoński <[email protected]> * fix: comments * feat: improve formatting of comments * feat: describe what unix epoch format is expected * fix: utc problem --------- Co-authored-by: Daniele Scasciafratte <[email protected]> Co-authored-by: Hubert Jabłoński <[email protected]> * Introduce optimizer - remove unused variables (#706) * feat: add scaffolding * feat: simple optimizer * feat: enable optimizer * feat: add transitive dependency support for optimizer * feat: remove unnecessary files * feat: clippy linting errors * feat: add support for detecting variable redeclaration and tracking conditional scopes * fix: transitive variables in conditional blocks are also used * refactor: add comments * feat: handle redeclared variables in conditional blocks * feat: add tests * refactor: clippy linting * feat: add test * chore(test): fix bash_error_exit_code of macos runner (#710) * fix: merge of subprocess with inner math resolution (#715) * Fix clippy::uninlined_format_args (#722) * docs: fix comment of UnOp group macro (#720) * fix: Disable some GNU Sed only features (#717) * fix: Disable GNU Sed only features * Apply rewording suggestions from code review Co-authored-by: Phoenix Himself <[email protected]> * chore(test): Shared test structure * chore(test): Include busybox sed test * Support BusyBox sed * Apply suggestions from code review Co-authored-by: Phoenix Himself <[email protected]> --------- Co-authored-by: Phoenix Himself <[email protected]> * feat(std/fs): Create cross OS compatible mktemp function (#718) * feat(std/fs): Create OSX compatible mktemp function * feat: Handle possible failure of mktemp * test: Use if chain * Apply suggestions from code review Co-authored-by: Phoenix Himself <[email protected]> --------- Co-authored-by: Phoenix Himself <[email protected]> * [BUG] Bad escaping for a string with \$ sequence #593 (#594) * fix: bad string escaping * feat: remove unused function * fix: bad variable interpolation * feat: Add "absurd cast" warning when casting Text to Bool (#719) * test: Add bash 5.3 matrix (#725) * Remove mistakenly added code in fs.ab (#730) * Add new `Int` type (#721) * feat: add int type * feat: add rest of the int functionality * fix: clippy * feat: make negation yield in case of parsing a number literal * fix: validity tests * feat: allow using Int with Num * fix: exit builtin now only accepts int * fix: grammar in error message * feat: improve subset mechnism to also cover arrays * fix: clippy * fix: remove inner quotes from arithmetic fragment * feat: add Type::Int where it's missing * fix: code review * feat: improve unreachables for eq and neq * feat: add support for comparing [Num] * feat: add tests and fix some bad behaviours * feat: add int for shorthand * fix: clippy * fix: clippy * feat: add ast comparison * feat: add snapshot based AST testing * Remove shfmt postprocessor support as it was rendered redundant (#735) * Add warning for invalid escape sequences in string literals (#732) * Initial plan * Add warning for invalid escape sequences in string literals Co-authored-by: Ph0enixKM <[email protected]> * Add comprehensive tests for invalid escape sequence warnings Co-authored-by: Ph0enixKM <[email protected]> * Fix Clippy warning: use inline format args Co-authored-by: Ph0enixKM <[email protected]> * Refactor escape sequence validation to eliminate unnecessary conditional checks Co-authored-by: Ph0enixKM <[email protected]> * Simplify escape sequence validation by reducing if statement and eliminating duplicate function Co-authored-by: Ph0enixKM <[email protected]> * Simplify escape sequence validation and fix indentation as requested by reviewer Co-authored-by: Ph0enixKM <[email protected]> * Pass token by value to avoid unnecessary cloning as requested by reviewer Co-authored-by: Ph0enixKM <[email protected]> * Fix warning positioning to highlight the exact invalid character in escape sequences Co-authored-by: Ph0enixKM <[email protected]> * Revert token positioning changes to use simpler string token highlighting Co-authored-by: Ph0enixKM <[email protected]> * Remove unnecessary token cloning by using references in escape sequence validation Co-authored-by: Ph0enixKM <[email protected]> * fix: highlight the correct section of the code --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> Co-authored-by: Phoenix Himself <[email protected]> * feat: Give auto deletion funtionality to temp_dir_create() (#726) * feat: Give auto deletion funtionality to temp_dir_create() * test: Use temp_dir_create function instead of direct command call * Update fs_file_chmod.ab * Update fs.ab * feat: add trim --------- Co-authored-by: Phoenix Himself <[email protected]> * chore(text.ab): Rename the parameters to source and search (#742) * Add optimizer for ephemeral (intermediate) variables (#728) * feat: add ephermal var optimizer * fix: clean up * feat: add tests * fix: cargo clippy * feat: improve ephemeral var optimizer * faet: improve algorithm to be in O(n) time * feat: remove new snapshots * feat: add ephemeral tests * ignore escaped newline in comments (#741) * ignore escaped newline in comments * feat: bump heraclitus * feat: make validity tests to also test the STDERR * fix: index out of bounds in other tests --------- Co-authored-by: Phoenix Himself <[email protected]> * feat: test for unused variables that are assigned to any subprocess (#746) * Fix remove global variables in functions (#729) * fix: global variables in functions * fix: clippy * fix: clippy * feat: add test * Loop iterator has to be Int (#752) * feat: iterator is now Int * feat: add tests * Fix concurrency issue in input tests by using unique temporary files (#756) * Initial plan * Fix concurrency issue in input tests by using unique temporary files Co-authored-by: Ph0enixKM <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> * Fix import statement error handling for star (*) in closure with helpful message (#755) * Initial plan * Implement error handling for star in import closure with helpful message Co-authored-by: Ph0enixKM <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> * Refactor CLI tests to use internal API with inline logic for improved simplicity * Initial plan * Refactor CLI tests to use internal API instead of external binary Co-authored-by: Ph0enixKM <[email protected]> * Fix clippy warning: remove redundant field assignment in CLI tests Co-authored-by: Ph0enixKM <[email protected]> * Improve CLI tests readability with helper functions and add message count assertion Co-authored-by: Ph0enixKM <[email protected]> * Refactor CLI tests with assertSingleWarning function as requested Co-authored-by: Ph0enixKM <[email protected]> * Simplify CLI tests to use single warning pattern only as requested Co-authored-by: Ph0enixKM <[email protected]> * Inline helper function logic and simplify error handling with unwrap calls as requested Co-authored-by: Ph0enixKM <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> * Implement support for reverse range expressions (fixes #471) (#753) * Initial plan * Implement reverse range support with compile-time and runtime detection Co-authored-by: Ph0enixKM <[email protected]> * Refactor range translate method into smaller, more readable functions Co-authored-by: Ph0enixKM <[email protected]> * Rename variable to_raw to to for consistency with from variable Co-authored-by: Ph0enixKM <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> Co-authored-by: Phoenix Himself <[email protected]> * feat: improve escaping (#759) * Add new and simpler release pipeline (#758) * feat: add new and simpler release pipeline * feat: remove cargo-dist * feat: new installer * feat: update installer script * Update release.yml Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Implement `while` loop feature for Amber language (#762) * Initial plan * Implement while loop feature with grammar, parsing, translation, and tests Co-authored-by: Ph0enixKM <[email protected]> * Address PR feedback: fix error handling, use += syntax, inline output comments, remove redundant test Co-authored-by: Ph0enixKM <[email protected]> * Fix clippy warning by using vec! macro directly instead of push pattern Co-authored-by: Ph0enixKM <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> * Fix: Unused variables optimizer removes variables also in case of shorthand expression (#763) * fix: optimizer - unused variables * feat: improve tests for optimizing * Unify block parsing to support both single-line and multi-line blocks consistently (#765) * Initial plan * Implement unified block parsing for single-line and multi-line blocks Co-authored-by: Ph0enixKM <[email protected]> * Refactor Block parsing to handle unified syntax in parse() method as requested Co-authored-by: Ph0enixKM <[email protected]> * Refactor Block::parse() to use requested approach with token consumption pattern Co-authored-by: Ph0enixKM <[email protected]> * feat: unified way to write blocks * feat: update while loop --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> Co-authored-by: Phoenix Himself <[email protected]> * Implemented AMBER_HEADER and AMBER_FOOTER variables (#682) * Implemented AMBER_HEADER and AMBER_FOOTER variables * rewrite dynamic header & footer to be consistent with the rest of the codebase * hardcode newlines after header & result * feat: resolve conflicts * feat: create gen_header and gen_footer functions * remove debug calls * feat: improve error message format --------- Co-authored-by: blek! <[email protected]> Co-authored-by: Daniele Scasciafratte <[email protected]> Co-authored-by: Phoenix Himself <[email protected]> * Update standard library to use `Int` data types (#768) * feat: update standard library * Update comments * Improve errors when no `failed` block used after failable expression (#769) * feat: better handle failed block error * feat: handle commands * fix: clippy * feat: add tests * Update missing functions (#774) * fix: nested arrays (#780) * Introduce an intermediate state of texts between parsing and translating (#772) * Introduce interpolated_region module - literal text and command are parsed to a rust strings at first. * stdlib: A negative offset must be separated from the colon https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html * Do not escape quote in command * stdlib: Escape single \ in texts * Add a command escaped test * Remove unnecessary peekable() * Surround raw string with `#` * Re-add missed exclamation mark handling * Implement to_char for InterpolatedRegionType * Implement `succeeded` block for handling command and function success (#787) * Initial plan * Implement succeeded block feature with basic functionality Co-authored-by: Ph0enixKM <[email protected]> * Complete succeeded block implementation with comprehensive tests Co-authored-by: Ph0enixKM <[email protected]> * Clean up test files based on code review feedback Co-authored-by: Ph0enixKM <[email protected]> * Remove unused is_main field from Succeeded struct Co-authored-by: Ph0enixKM <[email protected]> * Add echo "Succeeded" to function_succeeded_fail test Co-authored-by: Ph0enixKM <[email protected]> * Shorten tests --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> Co-authored-by: lens0021 <[email protected]> * Fix reversed ranges on Linux (#785) * fix: reversed ranges * fix: case of empty range * fix: update tests * docs(stdlib): Fix typos (#790) * docs(stdlib): Fix typos * docs: Fix more typos * Delete build.ab (#793) * docs: Exactly describe the current behaviors of std/array (#788) * Document the failure of addar_extract_at Removed at b6e57a8#diff-669cad100ed752df0476499d4b3752259de172ba6483c77c848b95765e3aa57c * docs: array_remove_at returns Null always * docs: Reflect the current behavior of array_last * docs: array_pop fails if the array is empty * chore!(stdlib): Make five stdlib functions failable instead of returning a bool (#791) * Make four stdlib functions to failable instead of returning bool * Make dir_create failable * fix: Use globally unique id for the arguments of the main function (#796) * fix: Use globally unique id for arguments of the main function * Use local args * Make array_first and array_shift failable when the array is empty (#789) * Migrate tests bash calls to builtin (#794) * Implement `sudo` command modifier (#782) * Initial plan * Implement sudo command modifier with detection logic and comprehensive tests Co-authored-by: Ph0enixKM <[email protected]> * Fix sudo modifier to use runtime detection instead of compile-time detection Co-authored-by: Ph0enixKM <[email protected]> * Refactor sudo implementation to use __sudo variable name and VarStmtFragment/VarExprFragment Co-authored-by: Ph0enixKM <[email protected]> * Simplify sudo detection to use concise bash logic and return just VarExprFragment Co-authored-by: Ph0enixKM <[email protected]> * Update sudo modifier error message for better consistency Co-authored-by: Ph0enixKM <[email protected]> * Clean up code by removing comments from gen_sudo_prefix function Co-authored-by: Ph0enixKM <[email protected]> * feat: update grammar ebnf * feat: properly test sudo * fix: typo * Remove else clause from chained modifiers sudo test as requested Co-authored-by: Ph0enixKM <[email protected]> * Simplify sudo test condition by removing root user check Co-authored-by: Ph0enixKM <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> Co-authored-by: Phoenix Himself <[email protected]> * feat(std/array): Add `array_filled` (#783) * feat(std): array_filled * Remove test for array_filled * Add default value to `array_filled` * Change description of `array_filled` * Change comments to triple slash * Apply suggestions from code review Change type tests for stronger assertion. Co-authored-by: Paweł Karaś <[email protected]> --------- Co-authored-by: Paweł Karaś <[email protected]> * [Feature] Add `then` block for handling command exit codes (#800) * Initial plan * Implement core then block functionality Co-authored-by: Ph0enixKM <[email protected]> * Fix then block tests and complete implementation Co-authored-by: Ph0enixKM <[email protected]> * Clean up imports and finalize then block implementation Co-authored-by: Ph0enixKM <[email protected]> * Address PR feedback: simplify conditions, use VarStmtFragment, optimize empty blocks Co-authored-by: Ph0enixKM <[email protected]> * Address all PR feedback: remove unused fields, use Type::Int, use variable function, wrap in context Co-authored-by: Ph0enixKM <[email protected]> * Final cleanup: remove unused comments, use VarStmtFragment builder pattern, improve error handling Co-authored-by: Ph0enixKM <[email protected]> * Remove unused set_position and set_function_name methods from Then struct Co-authored-by: Ph0enixKM <[email protected]> * Debug: Investigating __status variable issue in trust contexts Co-authored-by: Ph0enixKM <[email protected]> * Fix trust context regression and type consistency: use Type::Int for __status, return __status in empty blocks Co-authored-by: Ph0enixKM <[email protected]> * WIP: Add lookahead for then( pattern to avoid ternary expression conflict - still debugging Co-authored-by: Ph0enixKM <[email protected]> * Revert WIP lookahead commit - back to working state before ternary conflict investigation Co-authored-by: Ph0enixKM <[email protected]> * fix: then command modifier --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> Co-authored-by: Phoenix Himself <[email protected]> * Use recent syntax and stdlib in install.ab (#792) * chore: Use latest sytax in install.ab * Use new succeeded syntax * dir_create() now failable * Add parameter support to failed block for capturing exit codes (#806) * Initial plan * Add parameter support to failed block Co-authored-by: Ph0enixKM <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> * Improve error message for '?' operator usage (#805) * Improve error message for '?' operator usage * Update error messages to include operator '?' * Fix error message for '?' operator usage * Update src/modules/condition/failed.rs Co-authored-by: Lens0021 / Leslie <[email protected]> * Update error message for failed function call * Update documentation for failed command syntax Clarify error message for failed commands in documentation. * Fix error message for failed command handling * Correct error message for failed command syntax * Update error messages for failed command handling * Fix error message for failed command syntax Updated error message to include 'then' in command syntax. --------- Co-authored-by: Lens0021 / Leslie <[email protected]> * Remove `__` prefix from variable and function names in generated Bash code (#804) * Initial plan * Implement new variable and function naming convention Co-authored-by: Ph0enixKM <[email protected]> * Update snapshot tests for new naming convention Co-authored-by: Ph0enixKM <[email protected]> * Address PR feedback: improve wording and calculate is_all_caps dynamically Co-authored-by: Ph0enixKM <[email protected]> * Centralize is_all_caps function in utils/mod.rs Co-authored-by: Ph0enixKM <[email protected]> * Add gen_variable_prefix method to TranslateMetadata and update usage Co-authored-by: Ph0enixKM <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> * Correct interpolation within single-quoted strings in commands (#808) * Remove rotten TODOs (#809) * Ignore double-quoted single quote when escaping (#814) * Add more reserved words (#812) * Add more reserved words * `while` * Remove __ prefix from args of the main function (#817) * Stabilize single-quoted command interpolation (third fix) (#819) * Add more quote escaping tests * Fix single-quote balancing when rendering interpolated fragments * chore: Remove unused variables * Fix single-quote reopening for interpolated commands * Add test which has single quoted multiple interpolates --------- Co-authored-by: Codex [bot] <[email protected]> * Fix main args global id reuse in translation (#825) Co-authored-by: Codex [bot] <[email protected]> * Revert "Add warning for invalid escape sequences in string literals (#732)" (#823) * Revert "Add warning for invalid escape sequences in string literals (#732)" * Remove a validate_text_escape_sequences call * Separate type-checking from ParsingModule to new TypeCheckModule trait (#770) * Initial plan * Implement TypeCheckModule trait and update BinOp, UnOp, TypeOp implementations Co-authored-by: Ph0enixKM <[email protected]> * Complete TypeCheckModule implementation for shorthand operations Co-authored-by: Ph0enixKM <[email protected]> * Add type checking phase to compiler and implement TypeCheckModule for core syntax modules Co-authored-by: Ph0enixKM <[email protected]> * Fix clippy errors and warnings Co-authored-by: Ph0enixKM <[email protected]> * Fix recursive type checking in nested syntax modules Co-authored-by: Ph0enixKM <[email protected]> * Address minor issues: move type checks, remove comments, fix imports, add test Co-authored-by: Ph0enixKM <[email protected]> * Simplify match statement in fail.rs and move comments to top in test file Co-authored-by: Ph0enixKM <[email protected]> * Fix missing recursive typecheck calls in binop, unop, and typeop operators Co-authored-by: Ph0enixKM <[email protected]> * Move type assignments from parse phase to typecheck phase Co-authored-by: Ph0enixKM <[email protected]> * Move handle_variable_reference calls to typecheck phase and fix array literal defaults Co-authored-by: Ph0enixKM <[email protected]> * Store token positions in module structures and remove moved-code comments Co-authored-by: Ph0enixKM <[email protected]> * Remove unnecessary Option::is_some() checks in typecheck implementations Co-authored-by: Ph0enixKM <[email protected]> * Fix variable reference handling by moving VariableGet logic to typecheck phase Co-authored-by: Ph0enixKM <[email protected]> * Fix compilation errors in VariableGet by adding missing tok field Co-authored-by: Ph0enixKM <[email protected]> * Minor formatting * Print the array type state in an error message * fix: update types after typecheck * feat: refactor functions * feat: fix variables and arrays * fix: loops * feat: finish typecheck transition * feat: resolve clippy errors --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> Co-authored-by: Paweł Karaś <[email protected]> Co-authored-by: lens0021 <[email protected]> * Added improvements to stdlib (#821) * Remove dbg call * feat: update staging with keyword rename * fix: Text cannot be casted at all (#832) * fix: fail now proprely validates a variable (#836) * Refactor `Statement` module (#839) * feat: refactor statement * fix: remove unused macros * Function body is parsed when not called (#830) * fix: function body is parsed when not called * feat: add test * Resolve issues with not covered warnings in tests (#841) * feat: remove warnings * feat: fix warnings * fix: make sed_version work on BSD * feat: update docs generator script dosc.ab * Optimize docs gen usage examples for LSP (#843) * feat: update standard library doc gen * feat: update level for usage term * feat: improve doc gen * feat: bump amber version (#760) * Release 0.5.0-alpha --------- Co-authored-by: Lens0021 / Leslie <[email protected]> Co-authored-by: Huw Walters <[email protected]> Co-authored-by: blek! <[email protected]> Co-authored-by: Mohamed Magdi <[email protected]> Co-authored-by: Daniele Scasciafratte <[email protected]> Co-authored-by: Aleksana <[email protected]> Co-authored-by: Karim Vergnes <[email protected]> Co-authored-by: Hubert Jabłoński <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Ph0enixKM <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Rudy Mendoza <[email protected]> Co-authored-by: Codex [bot] <[email protected]>
Separate type-checking from ParsingModule to new TypeCheckModule trait
Summary
This PR introduces a
TypeCheckModuletrait that separates type-checking logic from parsing across all modules in the Amber compiler, establishing a clean compilation pipeline: tokenize → parse → typecheck → translate.Key Changes
New TypeCheckModule Trait
Compiler Pipeline Integration
typecheck()phase incompiler.rsbetween parsing and translationOperation Traits Updated
All operation traits now require
TypeCheckModuleas a supertrait:BinOp,UnOp,TypeOp,TernOpImplementation Coverage
40+ modules updated with complete phase separation:
Operators (17 modules)
typecheck()calls on child expressions before validationCore Modules
parse()totypecheck()Variable System
handle_variable_reference()totypecheck()typecheck()Control Flow & Functions
Architecture Benefits
Example
Before:
After:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.